public class learn {


import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeSet;

    /*
    创建一个牌组 ；通过程序实现洗牌，发牌，看牌；
     1.HashMap 健是编号，值是牌
     2.ArrayList 存储编号
     */
    public class PokerDemo {

        public static void main(String[] args) {
            HashMap<Integer,String> hs = new HashMap<>();
            ArrayList<Integer> array = new ArrayList<>();

            //装牌
            String[] colors = {"♠","♥","♦","♣"};
            String[] numbers = {"2","3","4","5","6","7","9","10","J","Q","K","A"};
            int index = 0;
            for(String number: numbers) {
                for(String color: colors) {
                    hs.put(index,color + number);
                    array.add(index);
                    index++;
                }

            }
            hs.put(index,"小王");
            array.add(index);
            index++;
            hs.put(index,"大王");
            array.add(index);
            Collections.shuffle(array);//随机洗牌

            //发牌了哦
            TreeSet<Integer> www1 = new TreeSet<>();
            TreeSet<Integer> www2 = new TreeSet<>();
            TreeSet<Integer> www3 = new TreeSet<>();
            TreeSet<Integer> dp = new TreeSet<>();

            for(int i = 0; i < array.size();i++){
                int poker = array.get(i);
                if(i >= array.size() - 3){
                    dp.add(poker);
                }else if(i % 3 ==0){
                    www1.add(poker);
                }else if(i % 3 ==1){
                    www2.add(poker);
                }else if(i % 3 ==2){
                    www3.add(poker);
                }
            }


            //看牌的方法
            lookPoker("www1" , www1, hs);
            lookPoker("www2" , www2, hs);
            lookPoker("www3" , www3, hs);
            lookPoker("底牌",dp, hs);
        }
        public static void lookPoker(String name , TreeSet<Integer> ts, HashMap<Integer,String> hs) {
            System.out.println(name + "的牌是");
            for(Integer poker : ts){
                String s = hs.get(poker);
                System.out.print( s + " ");
            }
            System.out.println();
        }

    }

}
